Skip to content

fix: make the arguments filter work on mysql and sqlite - #56

Merged
vishaltps merged 5 commits into
vishaltps:mainfrom
phmunhoz:fix/arguments-filter-cross-adapter
Nov 28, 2026
Merged

vishaltps merged 5 commits into
vishaltps:mainfrom
phmunhoz:fix/arguments-filter-cross-adapter

Conversation

@phmunhoz

@phmunhoz phmunhoz commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

The arguments filter answers 500 on MySQL and SQLite on every page that offers it (Failed, Ready, Scheduled, In Progress and Recurring Jobs, and the queue details page):

ActiveRecord::StatementInvalid: Mysql2::Error: You have an error in your SQL syntax; ... near '::text ILIKE '%...%'))'

It was built as arguments::text ILIKE ?, which only PostgreSQL accepts. The suite runs on SQLite only and never exercised the filter, so it went unnoticed. We hit it in production on MySQL.

Changes

  • Arguments filter. It now uses Arel's matches, which renders ILIKE on PostgreSQL and LIKE on the others, so the search still ignores case on all three. % and _ in the search term are escaped and match literally. The pattern goes in as a quoted node rather than a String. Solid Queue serializes arguments (JSON on Job, ActiveJob arguments on RecurringTask), and Arel casts a plain String through that coder, which would wrap the pattern in JSON quotes so that nothing matches. The spec stubs now serialize arguments the way the real models do, so the suite catches this.
  • Overview chart on MySQL. Running the suite on MySQL also showed that the chart used UNIX_TIMESTAMP, which reads a DATETIME in the session time zone, while Rails stores UTC. On any non-UTC server every bucket moved by the server's offset, and jobs near the edge of the window fell out of the chart. It now uses TIMESTAMPDIFF(SECOND, '1970-01-01 00:00:00', col), which doesn't depend on the time zone.
  • Suite on other adapters. spec_helper.rb reads DATABASE_URL, and in-memory SQLite stays the default. The mysql2 and pg gems are in optional Bundler groups, so a plain bundle install needs neither client library. CI gets two new jobs that run the full suite on MySQL 8 (with the server set to America/Sao_Paulo, so time zone bugs show up) and on PostgreSQL 16. The README's Development section explains how to run the suite on MySQL or PostgreSQL locally.

Testing

  • New spec/requests/solid_queue_monitor/arguments_filter_spec.rb covers every page with the filter, for case-insensitive matching and for a literal %.
  • Checked by hand in a Rails 8.1 app on MySQL with about 425k production jobs. Filtering failed jobs by argument text now returns the expected rows, where it used to return a 500.

@phmunhoz
phmunhoz requested a review from vishaltps as a code owner November 24, 2026 01:10
@phmunhoz
phmunhoz force-pushed the fix/arguments-filter-cross-adapter branch from deb79ff to 2ccfa40 Compare November 24, 2026 01:37
@phmunhoz
phmunhoz marked this pull request as draft November 24, 2026 01:51
@phmunhoz
phmunhoz marked this pull request as ready for review November 24, 2026 02:23
vishaltps
vishaltps previously approved these changes Nov 24, 2026
@vishaltps
vishaltps merged commit eae9251 into vishaltps:main Nov 28, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants